package com.ruoyi.basebill.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.basebill.domain.OmsPurinwarehsbill;
import com.ruoyi.basebill.service.IOmsPurinwarehsbillService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 采购入库单Controller
 * 
 * @author wenyixiong
 * @date 2023-02-15
 */
@RestController
@RequestMapping("/settlementCenter/basebill/purinwarehsbill")
public class OmsPurinwarehsbillController extends BaseController
{
    @Autowired
    private IOmsPurinwarehsbillService omsPurinwarehsbillService;

    /**
     * 查询采购入库单列表
     */
    @PreAuthorize("@ss.hasPermi('settlementCenter/basebill:purinwarehsbill:list')")
    @GetMapping("/list")
    public TableDataInfo list(OmsPurinwarehsbill omsPurinwarehsbill)
    {
        startPage();
        List<OmsPurinwarehsbill> list = omsPurinwarehsbillService.selectOmsPurinwarehsbillList(omsPurinwarehsbill);
        return getDataTable(list);
    }

    /**
     * 导出采购入库单列表
     */
    @PreAuthorize("@ss.hasPermi('settlementCenter/basebill:purinwarehsbill:export')")
    @Log(title = "采购入库单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OmsPurinwarehsbill omsPurinwarehsbill)
    {
        List<OmsPurinwarehsbill> list = omsPurinwarehsbillService.selectOmsPurinwarehsbillDetailList(omsPurinwarehsbill);
        ExcelUtil<OmsPurinwarehsbill> util = new ExcelUtil<OmsPurinwarehsbill>(OmsPurinwarehsbill.class);
        util.exportExcel(response, list, "采购入库单数据");
    }

    /**
     * 获取采购入库单详细信息
     */
    @PreAuthorize("@ss.hasPermi('settlementCenter/basebill:purinwarehsbill:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(omsPurinwarehsbillService.selectOmsPurinwarehsbillById(id));
    }

    /**
     * 新增采购入库单
     */
    @PreAuthorize("@ss.hasPermi('settlementCenter/basebill:purinwarehsbill:add')")
    @Log(title = "采购入库单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OmsPurinwarehsbill omsPurinwarehsbill)
    {
        return toAjax(omsPurinwarehsbillService.insertOmsPurinwarehsbill(omsPurinwarehsbill));
    }

    /**
     * 修改采购入库单
     */
    @PreAuthorize("@ss.hasPermi('settlementCenter/basebill:purinwarehsbill:edit')")
    @Log(title = "采购入库单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OmsPurinwarehsbill omsPurinwarehsbill)
    {
        return toAjax(omsPurinwarehsbillService.updateOmsPurinwarehsbill(omsPurinwarehsbill));
    }

    /**
     * 删除采购入库单
     */
    @PreAuthorize("@ss.hasPermi('settlementCenter/basebill:purinwarehsbill:remove')")
    @Log(title = "采购入库单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(omsPurinwarehsbillService.deleteOmsPurinwarehsbillByIds(ids));
    }
}
